package com.zhuiYun.project.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Collection;

/**
 * @author: HKY
 * @date: 2023年04月17日 16:33
 * @ClassName: DisposableBeanImpl
 * @Description: TODO
 */
@Component
@Slf4j
public class DisposableBeanImpl implements DisposableBean {
    @Resource
    private RedisTemplate redisTemplate;
    @Override
    public void destroy() {
        Collection<String> keys = redisTemplate.keys("*");
        redisTemplate.delete(keys);
        log.info("销毁：DisposableBeanImpl.destroy");
    }
}
